package com.xyzq.dao.sm.hibernate;

import java.util.Date;
import java.util.List;

import org.appfuse.dao.hibernate.GenericDaoHibernate;
import org.appfuse.model.User;
import org.springframework.stereotype.Repository;

import com.xyzq.dao.sm.DepositoryBusinessDAO;
import com.xyzq.model.sm.DepositoryBusiness;

@Repository("depositoryBusinessDao")
public class DepositoryBusinessDaoHibernate extends
		GenericDaoHibernate<DepositoryBusiness, Long> implements
		DepositoryBusinessDAO {

	public DepositoryBusinessDaoHibernate() {
		super(DepositoryBusiness.class);
	}

	public List<DepositoryBusiness> findByUser(User user) {
		// TODO Auto-generated method stub
		List list=getHibernateTemplate().find(
				"from DepositoryBusiness where FK_USER_USER=?", user.getId());
		if (list.isEmpty()) {
			return null;
		}
		return list;
	}

	public Boolean findByDateAndUser(User user, Date day) {
		// TODO Auto-generated method stub
		List list = getHibernateTemplate().find(
				"from DepositoryBusiness where FK_USER_USER=? and workDate=?",
				user.getId(), day);
		if (list.isEmpty()) {
			return false;
		}
		return true;
	}

}
